package org.point.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.point.common.dao.impl.BaseDaoImpl;
import org.point.common.util.DoPage;
import org.point.dao.CreditsRecordDao;
import org.point.domain.CreditsRecord;
import org.springframework.stereotype.Repository;

/**
 * 
 * @ClassName: CreditsRecordDaoImpl  
 * @Description: TODO(积分记录数据实现类)  
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午3:33:02  
 *
 */
@Repository("creditsRecordDao")
public class CreditsRecordDaoImpl extends BaseDaoImpl<CreditsRecord, Serializable> implements CreditsRecordDao {

	/**
	 * 利用反射，获取mapper.xml的namespace
	 * <p>Title: </p>  
	 * <p>Description: </p>
	 */
	public CreditsRecordDaoImpl() {
		namespace = super.getNamespace();
	}
	
	// 根据会员单位查询积分记录列表
	public static final String SQLID_FINDCRECFORMEM = "find_CRec_For_Mem";
	public static final String SQLID_FINDCRECFORMEMPAGE = "find_CRec_For_Mem_Page";
	// 根据会员单位查询积分记录数	
	public static final String SQLID_COUNTCRECFORMEMPAGE = "count_CRec_For_Mem_Page";
	// 会员单位新增积分记录
	public static final String SQLID_INSERTCREC = "insert_CRec";
	// 修改积分记录状态
	public static final String SQLID_UPDSTATUS = "upd_Status";

	public List<CreditsRecord> findCRecForMem(Map<String, Object> map) {
		List<CreditsRecord> records = getSqlSession().selectList(namespace + SQLID_FINDCRECFORMEM, map);
		return records;
	}

	public List<CreditsRecord> findCRecForMem(DoPage<CreditsRecord> page) {
		List<CreditsRecord> records = null;
		try {
			records = getSqlSession().selectList(namespace + SQLID_FINDCRECFORMEMPAGE, page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return records;
	}

	public Integer countCRecForMem(DoPage<CreditsRecord> page) {
		Integer result = 0;
		try {
			result = getSqlSession().selectOne(namespace + SQLID_COUNTCRECFORMEMPAGE, page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	public Integer inertCRec(CreditsRecord record) {
		Integer result = getSqlSession().insert(namespace + SQLID_INSERTCREC, record);
		return result;
	}

	public Integer updStatus(Map<String, Object> map) {
		Integer result = getSqlSession().update(namespace + SQLID_UPDSTATUS, map);
		return result;
	}


	
}
